 package server.maps;

 import client.MapleCharacter;
 import handling.world.WorldBroadcastService;
 import java.awt.Point;
 import server.MapleItemInformationProvider;
 import server.Timer;
 import server.life.MapleLifeFactory;
 import tools.MaplePacketCreator;
 import tools.Randomizer;

 public class AramiaFireWorks
 {
   public static final int KEG_ID = 4001128;
   public static final int SUN_ID = 4001246;
   public static final int DEC_ID = 4001473;
/*  17 */   private static final int[] arrayMob = new int[] { 9500168, 9500169, 9500170, 9500171, 9500173, 9500174, 9500175, 9500176, 9500170, 9500171, 9500172, 9500173, 9500174, 9500175, 9400569 }; public static final int MAX_KEGS = 2400; public static final int MAX_SUN = 3000; public static final int MAX_DEC = 3600;
/*  18 */   private static final int[] arrayX = new int[] { 2100, 2605, 1800, 2600, 3120, 2700, 2320, 2062, 2800, 3100, 2300, 2840, 2700, 2320, 1950 };
/*  19 */   private static final int[] arrayY = new int[] { 574, 364, 574, 316, 574, 574, 403, 364, 574, 574, 403, 574, 574, 403, 574 };
/*  20 */   private static final int[] array_X = new int[] { 720, 180, 630, 270, 360, 540, 450, 142, 142, 218, 772, 810, 848, 232, 308, 142 };
/*  21 */   private static final int[] array_Y = new int[] { 1234, 1234, 1174, 1234, 1174, 1174, 1174, 1260, 1234, 1234, 1234, 1234, 1234, 1114, 1114, 1140 };
   private static final int flake_Y = 149;
/*  23 */   private short kegs = 400;
/*  24 */   private short sunshines = 500;
/*  25 */   private short decorations = 600;

   public void giveKegs(MapleCharacter c, int kegs) {
/*  28 */     this.kegs = (short)(this.kegs + kegs);
/*  29 */     if (this.kegs >= 2400) {
/*  30 */       this.kegs = 0;
/*  31 */       broadcastEvent(c);
     }
   }

   private void broadcastServer(MapleCharacter c, int itemid) {
/*  36 */     WorldBroadcastService.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(6, itemid, "<频道 " + c.getClient().getChannel() + "> " + c.getMap().getMapName() + " : The amount of {" + MapleItemInformationProvider.getInstance().getName(itemid) + "} has reached the limit!"));
   }

   public short getKegsPercentage() {
/*  40 */     return (short)(this.kegs / 2400 * 10000);
   }

   private void broadcastEvent(MapleCharacter c) {
/*  44 */     broadcastServer(c, 4001128);

/*  46 */     Timer.EventTimer.getInstance().schedule(() -> startEvent(c.getClient().getChannelServer().getMapFactory().getMap(100000200)), 10000L);
   }

   private void startEvent(MapleMap map) {
/*  50 */     map.startMapEffect("Who's going crazy with the fireworks?", 5121010);

/*  52 */     Timer.EventTimer.getInstance().schedule(() -> spawnMonster(map), 5000L);
   }


   private void spawnMonster(MapleMap map) {
/*  57 */     for (int i = 0; i < arrayMob.length; i++) {
/*  58 */       Point pos = new Point(arrayX[i], arrayY[i]);
/*  59 */       map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(arrayMob[i]), pos);
     }
   }

   public void giveSuns(MapleCharacter c, int kegs) {
/*  64 */     this.sunshines = (short)(this.sunshines + kegs);

/*  66 */     MapleMap map = c.getClient().getChannelServer().getMapFactory().getMap(970010000);
/*  67 */     MapleReactor reactor = map.getReactorByName("mapleTree");
/*  68 */     for (int gogo = kegs + 500; gogo > 0; gogo -= 500) {
/*  69 */       switch (reactor.getState()) {
         case 0:
         case 1:
         case 2:
         case 3:
         case 4:
/*  75 */           if (this.sunshines >= 500 * (2 + reactor.getState())) {
/*  76 */             reactor.setState((byte)(reactor.getState() + 1));
/*  77 */             reactor.setTimerActive(false);
/*  78 */             map.broadcastMessage(MaplePacketCreator.triggerReactor(reactor));
           }
           break;
         default:
/*  82 */           if (this.sunshines >= 500) {
/*  83 */             map.resetReactors();
           }
           break;
       }
     }
/*  88 */     if (this.sunshines >= 3000) {
/*  89 */       this.sunshines = 0;
/*  90 */       broadcastSun(c);
     }
   }

   public short getSunsPercentage() {
/*  95 */     return (short)(this.sunshines / 3000 * 10000);
   }

   private void broadcastSun(MapleCharacter c) {
/*  99 */     broadcastServer(c, 4001246);

/* 101 */     Timer.EventTimer.getInstance().schedule(() -> startSun(c.getClient().getChannelServer().getMapFactory().getMap(970010000)), 10000L);
   }

   private void startSun(MapleMap map) {
/* 105 */     map.startMapEffect("The tree is bursting with sunshine!", 5121010);
/* 106 */     for (int i = 0; i < 3; i++) {
/* 107 */       Timer.EventTimer.getInstance().schedule(() -> spawnItem(map), (5000 + i * 10000));
     }
   }


   private void spawnItem(MapleMap map) {
/* 113 */     for (int i = 0; i < Randomizer.nextInt(5) + 10; i++) {
/* 114 */       Point pos = new Point(array_X[i], array_Y[i]);
/* 115 */       int itemId = 4001246;
/* 116 */       switch (Randomizer.nextInt(15)) {
         case 0:
         case 1:
/* 119 */           itemId = 3010141;
           break;
         case 2:
/* 122 */           itemId = 3010146;
           break;
         case 3:
         case 4:
/* 126 */           itemId = 3010025;
           break;
       }
/* 129 */       map.spawnAutoDrop(itemId, pos);
     }
   }

   public void giveDecs(MapleCharacter c, int kegs) {
/* 134 */     this.decorations = (short)(this.decorations + kegs);

/* 136 */     MapleMap map = c.getClient().getChannelServer().getMapFactory().getMap(555000000);
/* 137 */     MapleReactor reactor = map.getReactorByName("XmasTree");
/* 138 */     for (int gogo = kegs + 600; gogo > 0; gogo -= 600) {
/* 139 */       switch (reactor.getState()) {
         case 0:
         case 1:
         case 2:
         case 3:
         case 4:
/* 145 */           if (this.decorations >= 600 * (2 + reactor.getState())) {
/* 146 */             reactor.setState((byte)(reactor.getState() + 1));
/* 147 */             reactor.setTimerActive(false);
/* 148 */             map.broadcastMessage(MaplePacketCreator.triggerReactor(reactor));
           }
           break;
         default:
/* 152 */           if (this.decorations >= 600) {
/* 153 */             map.resetReactors();
           }
           break;
       }
     }
/* 158 */     if (this.decorations >= 3600) {
/* 159 */       this.decorations = 0;
/* 160 */       broadcastDec(c);
     }
   }

   public short getDecsPercentage() {
/* 165 */     return (short)(this.decorations / 3600 * 10000);
   }

   private void broadcastDec(MapleCharacter c) {
/* 169 */     broadcastServer(c, 4001473);
/* 170 */     Timer.EventTimer.getInstance().schedule(() -> startDec(c.getClient().getChannelServer().getMapFactory().getMap(555000000)), 10000L);
   }

   private void startDec(MapleMap map) {
/* 174 */     map.startMapEffect("The tree is bursting with snow!", 5120000);
/* 175 */     for (int i = 0; i < 3; i++) {
/* 176 */       Timer.EventTimer.getInstance().schedule(() -> spawnDec(map), (5000 + i * 10000));
     }
   }


   private void spawnDec(MapleMap map) {
/* 182 */     for (int i = 0; i < Randomizer.nextInt(10) + 40; i++) {
/* 183 */       Point pos = new Point(Randomizer.nextInt(800) - 400, 149);
/* 184 */       map.spawnAutoDrop((Randomizer.nextInt(15) == 1) ? 4310012 : 4310011, pos);
     }
   }
 }


/* Location:              C:\PGX\Server.jar!\server\maps\AramiaFireWorks.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */